﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.Module;

namespace LPV_POS.mh_pos
{
    public partial class mh_select__hhlienket : DevExpress.XtraEditors.XtraForm
    {
        thuvien tv;
        DataTable tb;
        string[] s;
        object[] o;
        public mh_select__hhlienket()
        {
            InitializeComponent();
        }
        #region cac ham va phuong thuc
            private DataTable showdataon_luoihhlienket()
            {
                s = new string[] {"@flag","@choose" };
                o = new object[] { 1,3};
                tv = new thuvien();
                tb = tv.SP_SelectDataTable("sp_mh_quanlykho", s, o);
                return tb;
            }
        #endregion

       
        private void mh_select__hhlienket_Load(object sender, EventArgs e)
        {
            luoi_hhlienket.MainView = grid_hhlienket;
            luoi_hhlienket.DataSource = showdataon_luoihhlienket();
        }

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            Variable.bool_close = true;
            this.Close();
        }

        private void bton_chon_Click(object sender, EventArgs e)
        {
            try
            {
                   Variable.str_mahhlienket   = grid_hhlienket.GetRowCellValue(grid_hhlienket.FocusedRowHandle,col_mahh). ToString();
                   Variable.str_tenhh = grid_hhlienket.GetRowCellValue(grid_hhlienket.FocusedRowHandle, col_tenhh).ToString();
              
                   this.Close();

            }
            catch (Exception)
            {
                  Mod_messagebox mess = new Mod_messagebox();
                  mess.messagebox_pos("Thông báo", "Kiểm tra lại việc chọn hàng hóa liên kết", loaithongbao.canhbao.GetHashCode());
            }

        }

        private void grid_hhlienket_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                Variable.str_mahhlienket = grid_hhlienket.GetRowCellValue(grid_hhlienket.FocusedRowHandle, col_mahh).ToString();
                Variable.str_tenhh = grid_hhlienket.GetRowCellValue(grid_hhlienket.FocusedRowHandle, col_tenhh).ToString();

                this.Close();

            }
            catch (Exception)
            {
                Mod_messagebox mess = new Mod_messagebox();
                mess.messagebox_pos("Thông báo", "Kiểm tra lại việc chọn hàng hóa liên kết", loaithongbao.canhbao.GetHashCode());
            }
        }

      
    }
}